<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="accountuser" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{accountuserHome.managed ? 'Edit' : 'Add'} Accountuser</f:facet>


            <s:decorate id="usernameField" template="layout/edit.xhtml">
                <ui:define name="label">Username</ui:define>
                <h:inputTextarea id="username"
                               cols="80"
                               rows="10"
                           disabled="#{accountuserHome.managed}"
                           required="true"
                              value="#{accountuserHome.instance.username}"/>
            </s:decorate>


            <s:decorate id="firstnameField" template="layout/edit.xhtml">
                <ui:define name="label">Firstname</ui:define>
                <h:inputTextarea id="firstname"
                               cols="80"
                               rows="10"
                           required="true"
                              value="#{accountuserHome.instance.firstname}"/>
            </s:decorate>


            <s:decorate id="lastnameField" template="layout/edit.xhtml">
                <ui:define name="label">Lastname</ui:define>
                <h:inputTextarea id="lastname"
                               cols="80"
                               rows="10"
                           required="true"
                              value="#{accountuserHome.instance.lastname}"/>
            </s:decorate>


            <s:decorate id="userpasswordField" template="layout/edit.xhtml">
                <ui:define name="label">Userpassword</ui:define>
                <h:inputTextarea id="userpassword"
                               cols="80"
                               rows="10"
                           required="true"
                              value="#{accountuserHome.instance.userpassword}"/>
            </s:decorate>


            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{accountuserHome.persist}"
                       disabled="#{!accountuserHome.wired}"
                       rendered="#{!accountuserHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{accountuserHome.update}"
                       rendered="#{accountuserHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{accountuserHome.remove}"
                      immediate="true"
                       rendered="#{accountuserHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Accountuser.xhtml"
                rendered="#{accountuserHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty accountuserFrom ? 'AccountuserList' : accountuserFrom}.xhtml"
                rendered="#{!accountuserHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Expenses">
        <h:form styleClass="association" id="expensesChildren">

            <h:outputText value="There are no expenses associated with this accountuser."
                       rendered="#{empty accountuserHome.expenses}"/>

            <rich:dataTable value="#{accountuserHome.expenses}"
                           var="_expense"
                      rendered="#{not empty accountuserHome.expenses}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="expensesTable">
                <rich:column sortBy="#{_expense.expensename}">
                    <f:facet name="header">Expensename</f:facet>
                    <h:outputText value="#{_expense.expensename}"/>
                </rich:column>
                <rich:column sortBy="#{_expense.amount}">
                    <f:facet name="header">Amount</f:facet>
                    <h:outputText value="#{_expense.amount}">
                        <f:convertNumber/>
                    </h:outputText>
                </rich:column>
                <rich:column sortBy="#{_expense.expensecategory}">
                    <f:facet name="header">Expensecategory</f:facet>
                    <h:outputText value="#{_expense.expensecategory}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{accountuserHome.managed}" id="expenses">
        <div class="actionButtons">
            <s:button id="addexpense"
                   value="Add expense"
                    view="/ExpenseEdit.xhtml"
             propagation="none">
                 <f:param name="accountuserUsername"
                         value="#{accountuserHome.instance.username}"/>
                 <f:param name="expenseFrom" value="Accountuser"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
